package com.lagou.dao.Impl;


import com.lagou.dao.CourseDao;
import com.lagou.pojo.Course;
import com.lagou.utils.DruidUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

public class CourseDaoImpl implements CourseDao {

   @Override
   public List<Course> findCourseList() {
      try {
      QueryRunner qr = new QueryRunner(DruidUtils.getDataSource());
      String sql = "select id, course_name,price,,sort_num,status from course where is_del =?";

      List<Course> query = qr.query(sql, new BeanListHandler<Course>(Course.class), 0);
      return  query;
      } catch (SQLException e) {
         e.printStackTrace();
         return null;
      }
   }
}

